home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / tutorials / geometer / application.c next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.2 KB  |  112 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. #include "generic.h"
  19. #include "gizmo.h"
  20. #include <stdio.h>
  21. #include <gl.h>
  22. #include <device.h>
  23. #include <getopt.h>
  24. #include "parse.h"
  25.  
  26. void mainloop(), drawgeom();
  27.  
  28. extern int gd;
  29. void recalcsizes(), deleteallbuts(), initshowcaseui(), drawui();
  30.  
  31. void handleredraw()
  32. {
  33.     getwindowinfo();
  34.     remakepulldown();
  35.     recalcsizes();
  36.     drawgeom(); drawgeom();
  37.     deleteallbuts();
  38.     initshowcaseui();
  39.     viewport(0, (short)(xsize - 1), 0, (short)(ysize - PULLDOWNHEIGHT -1));
  40.     ortho2(-0.5, xsize-0.5, -0.5, ysize-PULLDOWNHEIGHT-0.5);
  41.     drawui();
  42. }
  43.  
  44. long readgeometry(char *);
  45. long insertgeometry(char *);
  46. void clearbuffer();
  47. void generichelp();
  48. void quit();
  49.  
  50. /* You've got to fill in slots in this structure with the application-
  51.  * specific routine names.  If you don't have a routine, just put zero
  52.  * in the slot.  You had better have a readfile and writefile, at least.
  53.  * 
  54.  * readfile() takes the file name, reads the contents into your
  55.  * internal data structures, and returns 1 if successful; 0 otherwise.
  56.  * 
  57.  * writefile() writes a file with the given name, and returns 1 if
  58.  * successful; zero otherwise.
  59.  * 
  60.  * errorwritefile() writes the file after a signal is caught.  This
  61.  * routine can be the same as writefile(), but you may want something
  62.  * more robust or different, since when this routine gets hit, there
  63.  * was probably a bad error.
  64.  * 
  65.  * insertfile() adds the contents of the named file to the application's
  66.  * internal data structures.
  67.  * 
  68.  * printfile() prints.  The application creates a print file with the
  69.  * given name, and then issues an 'lp' command, or whatever's appropriate.
  70.  * 
  71.  * makecheckpointname() creates the name of the checkpoint files.  By
  72.  * default, the file named 'foo' has a checkpoint name of 'foo.ckp'.  You
  73.  * may want to strip extensions, etc.
  74.  * 
  75.  * makebackupname() same as above, but for backup files.  The default
  76.  * backup name for 'foo' is 'foo.bak'.
  77.  * 
  78.  * clearbuffer() clears the application's data structures after something
  79.  * like a New command.
  80.  * 
  81.  * help() presents help (or indicates that none is available).
  82.  * 
  83.  * quit() cleans up stuff before quitting.
  84.  */
  85.  
  86. struct application_entries entries = {
  87.     readgeometry,
  88.     printall, 
  89.     printall, 
  90.     insertgeometry, 
  91.     dumpPostScript, 
  92.     0, 
  93.     0, 
  94.     clearbuffer, 
  95.     generichelp, 
  96.     quit
  97. };
  98.  
  99. void generichelp()
  100. {
  101.     fprintf(stderr, "No help available\n");
  102. }
  103.  
  104. void restore255();
  105.  
  106. void quit()
  107. {
  108.     drawmode(PUPDRAW); color(0); clear(); drawmode(NORMALDRAW);
  109.     restore255();
  110.     murdergizmos();
  111. }
  112.